package com.yociyy.sms.validate.code;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.yociyy.sms.validate.code.images.ImageCodeGenerator;
import com.yociyy.sms.validate.code.sms.DefaultsSmsCodeSender;
import com.yociyy.sms.validate.code.sms.SmsCodeSender;

/**
 * 验证码相关的扩展点配置。配置在这里的bean，业务系统都可以通过声明同类型或同名的bean来覆盖安全模块默认的配置,以增量的方式去适应变化
 *
 * @author: YoCiyy
 * @date: 2020/5/25
 */
@Configuration
public class ValidateCodeBeanConfig {

	@Bean
	@ConditionalOnMissingBean(name = "imageValidateCodeGenerator")
	public ValidateCodeGenerator imageValidateCodeGenerator() {
		return new ImageCodeGenerator();
	}

	@Bean
//	 @ConditionalOnMissingBean(name = "smsValidateCodeGenerator")
	@ConditionalOnMissingBean(SmsCodeSender.class)
	public SmsCodeSender smsValidateCodeGenerator() {
		return new DefaultsSmsCodeSender();
	}
}
